/*
 * @Author       : Bing Chen chenbing@iocharger.com
 * @Date         : 2024-05-20 15:18:35
 * @LastEditors  : Bing Chen chenbing@iocharger.com
 * @LastEditTime : 2025-03-15 12:56:18
 * @FilePath     : \openchaoji-corelib\shared\include\OpenChaoJi_def.h
 * @Description  : 描述18487和27930中EVCC/SECC通用的声明和宏定义等
 *
 * Copyright (c) 2025 OpenChaoJi
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the icense for the specific language governing permissions and
 * limitations under the License.
 *
 */


#ifndef __OPEN_CHAOJI_DEF_H__
#define __OPEN_CHAOJI_DEF_H__

#include "OpenChaoJi_config.h"
#include "OpenChaoJi_type.h"

#if ((OPENCHAOJI_CONFIG_ENABLE_GBT27930_A != CONFIG_YES) && (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B != CONFIG_YES))
#error "At least one of OPENCHAOJI_CONFIG_ENABLE_GBT27930_A and OPENCHAOJI_CONFIG_ENABLE_GBT27930_B must be enabled"
#endif

/**
 * 统一的模块状态定义, 32位表述, 高3位预留, 1位区分EVCC/SECC, 12位标识模块ID, 16位标识状态ID
*/
#define OPENCHAOJI_SECC_MODULE_STATUS_ID(MODULE,STATUS)  ((0 << 28) | ((((int)(MODULE)) & 0x0FFF) << 16) | ((((int)(STATUS)) & 0xFFFF) << 0))
#define OPENCHAOJI_EVCC_MODULE_STATUS_ID(MODULE,STATUS)  ((1 << 28) | ((((int)(MODULE)) & 0x0FFF) << 16) | ((((int)(STATUS)) & 0xFFFF) << 0))
#define OPENCHAOJI_MODULE_OF_ID(ID)                      ((int)((ID >> 16) & 0x0FFF))
#define OPENCHAOJI_STATUS_OF_ID(ID)                      ((int)((ID >>  0) & 0xFFFF))

/********************************** 通用声明  **********************************/
/**
 * 定义EVCC类别
 * 按照18487定义, 目前只有A类系统和B类系统两种
 * 1. EVCC可以只支持A类系统, 即仅使用20234.3-2023标准
 * 2. EVCC支持B类系统则默认兼容A类系统, 即使用20234.4标准, 同时支持通过适配器方案支持20234.3-2023标准
 * 本项目实施B类系统并兼容A类系统
*/
enum OpenChaoJi_evcc_gbt27930_type {

    OPENCHAOJI_EVCC_GBT27930_TYPE_UNDEFINED  = (1 << 0),

#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_A == CONFIG_YES)
    OPENCHAOJI_EVCC_GBT27930_TYPE_A          = (1 << 1),
#endif
#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B == CONFIG_YES)
    OPENCHAOJI_EVCC_GBT27930_TYPE_B          = (1 << 2),
#endif

    OPENCHAOJI_EVCC_GBT27930_TYPE_UNKNOWN    = (1 << 30)
};

/**
 * 定义SECC类别
 * 按照18487定义, 目前B类EVCC系统通过适配器除了支持A类系统外, 还可以支持AA/EE/FF三类系统
 * B类EVCC可以在初始化的时候根据实际情况决定支持哪些标准, 但是默认的A/B两类必须支持.
 * 本项目目前未支持AA/EE/FF, 仅作预留
*/
enum OpenChaoJi_secc_gbt27930_type {

    OPENCHAOJI_SECC_GBT27930_TYPE_UNDEFINED  = (1 << 0),

#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_A == CONFIG_YES)
    OPENCHAOJI_SECC_GBT27930_TYPE_A          = (1 << 1),
#endif
#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B == CONFIG_YES)
    OPENCHAOJI_SECC_GBT27930_TYPE_B          = (1 << 2),
#endif
    OPENCHAOJI_SECC_GBT27930_TYPE_CHADEMO    = (1 << 3),
    OPENCHAOJI_SECC_GBT27930_TYPE_CCS1       = (1 << 4),
    OPENCHAOJI_SECC_GBT27930_TYPE_CCS2       = (1 << 5),

    OPENCHAOJI_SECC_GBT27930_TYPE_UNKNOWN    = (1 << 30)
};

/*
 * 系统消息类型定义
*/
#define OpenChaoJi_MSG_ACK      1
#define OpenChaoJi_MSG_UNACK    0

enum OpenChaoJi_gbt27930_data_type {
    OPENCHAOJI_GBT27930_SYSTEM_A_MSG =  			0,  	//GBT27930 A类系统消息
    OPENCHAOJI_GBT27930_SYSTEM_B_LINKAGE_DATA  =  	1,   	//GBT27930 B类系统链路层数据
    OPENCHAOJI_GBT27930_SYSTEM_B_MSG  =  			2,   	//GBT27930 B类系统传输层消息
};

enum OpenChaoJi_gbt27930_msg_type {
    OPENCHAOJI_GBT27930_MSG_TYPE_URM =  0,  	//GBT27930 系统不需要确认消息
    OPENCHAOJI_GBT27930_MSG_TYPE_RM  =  1,   	//GBT27930 系统需要确认消息
};


/********************************** 18487  **********************************/
enum OpenChaoJi_pilot_status_gbt18487_a {

    OPENCHAOJI_PILOT_STATUS_GBT18487_A_DISCONNECT = 0,      // 未连接，12V
    OPENCHAOJI_PILOT_STATUS_GBT18487_A_CONNECTED,           // 完全连接，桩端4V, 车端6V
    OPENCHAOJI_PILOT_STATUS_GBT18487_A_S1_OPEN,             // 半连接(S1开路)，仅限桩端6V
    OPENCHAOJI_PILOT_STATUS_GBT18487_A_UNKNOWN,             // 未知状态(电压错误)

    OPENCHAOJI_PILOT_STATUS_GBT18487_A_NUM
};

#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B == CONFIG_YES)

enum OpenChaoJi_pilot_status_gbt18487_b {

    OPENCHAOJI_PILOT_STATUS_GBT18487_B_A,                   // 枪头未连接 0V 取值0～0.5V /*电压取值大于等于，小于*/
    OPENCHAOJI_PILOT_STATUS_GBT18487_B_Ap,                  // 枪头半连接 10.8V 取值9.3V～12V
    OPENCHAOJI_PILOT_STATUS_GBT18487_B_B,                   // 枪头连接/预约 2.34V 取值1.5V～4V
    OPENCHAOJI_PILOT_STATUS_GBT18487_B_C,                   // 充电机就绪/车辆停止 8.73V 取值7V～9.3V
    OPENCHAOJI_PILOT_STATUS_GBT18487_B_D,                   // 车辆能量传输  5.6V 取值4V～7V
    OPENCHAOJI_PILOT_STATUS_GBT18487_B_E,                   // 车辆准备就绪/充电机停止 0.88V 取值0.5V～1.5V
    OPENCHAOJI_PILOT_STATUS_GBT18487_B_UNKNOWN,             // 链接电压错误

    OPENCHAOJI_PILOT_STATUS_GBT18487_B_NUM
};
#endif

enum OpenChaoJi_elock_status{
    OPENCHAOJI_ELOCK_STATUS_UNLOCKED = 0x00, //未锁止
    OPENCHAOJI_ELOCK_STATUS_LOCKING  = 0xAA, //锁止中
    OPENCHAOJI_ELOCK_STATUS_LOCKED   = 0xDD, //锁止
    OPENCHAOJI_ELOCK_STATUS_OPENING  = 0x55, //解锁中
    OPENCHAOJI_ELOCK_STATUS_ERROR    = 0xEE, //电子锁故障
};



/********************************** A类系统  **********************************/
#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_A == CONFIG_YES)

/**
 * 定义A类系统模块序号分配, 用于module_status_id
*/
enum OpenChaoJi_gbt27930_a_module {

    OPENCHAOJI_GBT27930_A_MODULE_IDLE = 0,      // 空闲
    OPENCHAOJI_GBT27930_A_MODULE_TRIGGER,       // 导引控制, 低压辅助
    OPENCHAOJI_GBT27930_A_MODULE_HANDSHAKE,     // 充电握手
    OPENCHAOJI_GBT27930_A_MODULE_CONFIG,        // 参数配置
    OPENCHAOJI_GBT27930_A_MODULE_CHARGE,        // 充电
    OPENCHAOJI_GBT27930_A_MODULE_END,           // 充电结束
    OPENCHAOJI_GBT27930_A_MODULE_ERROR,         // 错误处理（通信超时）

    OPENCHAOJI_GBT27930_A_MODULE_NUM
};

/**
 * 定义A类系统地址分配
*/
#define OPENCHAOJI_GBT27930_A_CAN_ADDR_SECC  0x56
#define OPENCHAOJI_GBT27930_A_CAN_ADDR_EVCC  0xF4

/**
 * 定义A类系统PGN
*/
enum OpenChaoJi_gbt27930_a_PGNType {
    OPENCHAOJI_GBT27930_A_PGN_CHM           = 0x26,
    OPENCHAOJI_GBT27930_A_PGN_BHM           = 0x27,
    OPENCHAOJI_GBT27930_A_PGN_CRM           = 0x01,
    OPENCHAOJI_GBT27930_A_PGN_BRM           = 0x02,
    OPENCHAOJI_GBT27930_A_PGN_BCP           = 0x06,
    OPENCHAOJI_GBT27930_A_PGN_CTS           = 0x07,
    OPENCHAOJI_GBT27930_A_PGN_CML           = 0x08,
    OPENCHAOJI_GBT27930_A_PGN_BRO           = 0x09,
    OPENCHAOJI_GBT27930_A_PGN_CRO           = 0x0A,
    OPENCHAOJI_GBT27930_A_PGN_BCL           = 0x10,
    OPENCHAOJI_GBT27930_A_PGN_BCS           = 0x11,
    OPENCHAOJI_GBT27930_A_PGN_CCS           = 0x12,
    OPENCHAOJI_GBT27930_A_PGN_BSM           = 0x13,
    OPENCHAOJI_GBT27930_A_PGN_BMV           = 0x15,
    OPENCHAOJI_GBT27930_A_PGN_BMT           = 0x16,
    OPENCHAOJI_GBT27930_A_PGN_BSP           = 0x17,
    OPENCHAOJI_GBT27930_A_PGN_BST           = 0x19,
    OPENCHAOJI_GBT27930_A_PGN_CST           = 0x1A,
    OPENCHAOJI_GBT27930_A_PGN_BSD           = 0x1C,
    OPENCHAOJI_GBT27930_A_PGN_CSD           = 0x1D,
    OPENCHAOJI_GBT27930_A_PGN_BEM           = 0x1E,
    OPENCHAOJI_GBT27930_A_PGN_CEM           = 0x1F,
};

/**
 * 定义A类系统协议版本号
*/
#define OPENCHAOJI_GBT27930_A_PROTOCOL_VERSION_TYPE_MAKE(MAJOR,MINOR,TMP)   ((((int)MAJOR) << 16) | (((int)MINOR) << 8) | (((int)TMP) << 0))
#define OPENCHAOJI_GBT27930_A_PROTOCOL_VERSION_TYPE_MAJOR(VER)              ((((int)VER) >> 16) & 0xFF)
#define OPENCHAOJI_GBT27930_A_PROTOCOL_VERSION_TYPE_MINOR(VER)              ((((int)VER) >>  8) & 0xFF)
#define OPENCHAOJI_GBT27930_A_PROTOCOL_VERSION_TYPE_TMP(VER)                ((((int)VER) >>  0) & 0xFF)

#define OPENCHAOJI_GBT27930_A_PROTOCOL_VERSION_TYPE_1_1_0                   OPENCHAOJI_GBT27930_A_PROTOCOL_VERSION_TYPE_MAKE(1,1,0)

/**
 * 定义A类系统软件版本编译时间
*/
#define OPENCHAOJI_GBT27930_A_SOFTWARE_RELEASE_DATE_MAKE(YEAR,MONTH,DAY)    ((((int)YEAR) << 16) | (((int)MONTH) << 8) | (((int)DAY) << 0))
#define OPENCHAOJI_GBT27930_A_SOFTWARE_RELEASE_DATE                         OPENCHAOJI_GBT27930_A_SOFTWARE_RELEASE_DATE_MAKE(2024,11,8)

/**
 * 定义A类系统软件版本流水号(第几次编译)
*/
#define OPENCHAOJI_GBT27930_A_SOFTWARE_RELEASE_SN           0x01            // 软件版本流水号(第几次编译)

/**
 * 定义A类系统充电模式 ChargeModeType
*/
enum OpenChaoJi_gbt27930_a_ChargeModeType {
    OPENCHAOJI_GBT27930_A_CHARGE_MODE_TYPE_VOLTAGE           = 0x01,
    OPENCHAOJI_GBT27930_A_CHARGE_MODE_TYPE_CURRENT           = 0x02,
};

/**
 * 定义A类暂停状态 PauseStatusType
*/
enum OpenChaoJi_gbt27930_a_PauseStatusType {
    OPENCHAOJI_GBT27930_A_PAUSE_STATUS_PAUSE                 = 0x00,
    OPENCHAOJI_GBT27930_A_PAUSE_STATUS_CHARGE                = 0x01,
};

/**
 * 定义A类系统辨识结果 RecognizeType
*/
enum OpenChaoJi_gbt27930_a_RecognizeType {
    OPENCHAOJI_GBT27930_A_RECOGNIZE_TYPE_NOT_RECOGNIZED           = 0x00,
    OPENCHAOJI_GBT27930_A_RECOGNIZE_TYPE_RECOGNIZED               = 0xAA,
};

/**
 * 定义A类系统就绪状态 ReadyType
*/
enum OpenChaoJi_gbt27930_a_ReadyType {
    OPENCHAOJI_GBT27930_A_READY_TYPE_NOT_READY               = 0x00,
    OPENCHAOJI_GBT27930_A_READY_TYPE_READY                   = 0xAA,
};

/**
 * 定义A类系统电池类型 BattType
*/
enum OpenChaoJi_gbt27930_a_BattType {
    OPENCHAOJI_GBT27930_A_BATT_TYPE_LA                       = 0x01,
    OPENCHAOJI_GBT27930_A_BATT_TYPE_NIMH                     = 0x02,
    OPENCHAOJI_GBT27930_A_BATT_TYPE_LFP                      = 0x03,
    OPENCHAOJI_GBT27930_A_BATT_TYPE_LMO                      = 0x04,
    OPENCHAOJI_GBT27930_A_BATT_TYPE_LCO                      = 0x05,
    OPENCHAOJI_GBT27930_A_BATT_TYPE_NCM                      = 0x06,
    OPENCHAOJI_GBT27930_A_BATT_TYPE_PLB                      = 0x07,
    OPENCHAOJI_GBT27930_A_BATT_TYPE_LTO                      = 0x08,
    OPENCHAOJI_GBT27930_A_BATT_TYPE_OTHER                    = 0xFF,
};

/**
 * 定义A类系统就绪状态 ReadyType
*/
enum OpenChaoJi_gbt27930_a_BattPropertyType {
    OPENCHAOJI_GBT27930_A_BATT_PROPERTY_TYPE_RENTED          = 0x00,
    OPENCHAOJI_GBT27930_A_BATT_PROPERTY_TYPE_PRIVATE         = 0x01,
};

/**
 * 定义A类系统停机充电代码置位状态 StopCodeState
*/
enum OpenChaoJi_gbt27930_a_StopCodeState {
    OPENCHAOJI_GBT27930_A_STOPCODE_STATE_NORMAL              = 0x00,
    OPENCHAOJI_GBT27930_A_STOPCODE_STATE_SET                 = 0x01,
    OPENCHAOJI_GBT27930_A_STOPCODE_STATE_UNTRUSTED           = 0x02,
};

/**
 * 定义A类系统故障状态 FaultState
*/
enum OpenChaoJi_gbt27930_a_FaultState {
    OPENCHAOJI_GBT27930_A_FAULT_STATE_NORMAL                 = 0x00,
    OPENCHAOJI_GBT27930_A_FAULT_STATE_FAULT                  = 0x01,
    OPENCHAOJI_GBT27930_A_FAULT_STATE_UNTRUSTED              = 0x02,
};

/**
 * 定义A类系统故障状态 FaultState_CellVolt
*/
enum OpenChaoJi_gbt27930_a_FaultState_CellVolt {
    OPENCHAOJI_GBT27930_A_FAULT_STATE_CELLVOLT_NORMAL        = 0x00,
    OPENCHAOJI_GBT27930_A_FAULT_STATE_CELLVOLT_HIGH          = 0x01,
    OPENCHAOJI_GBT27930_A_FAULT_STATE_CELLVOLT_LOW           = 0x02,
};

/**
 * 定义A类系统故障状态 FaultState_SOC
*/
enum OpenChaoJi_gbt27930_a_FaultState_SOC {
    OPENCHAOJI_GBT27930_A_FAULT_STATE_SOC_NORMAL             = 0x00,
    OPENCHAOJI_GBT27930_A_FAULT_STATE_SOC_HIGH               = 0x01,
    OPENCHAOJI_GBT27930_A_FAULT_STATE_SOC_LOW                = 0x02,
};

/**
 * 定义A类系统超时状态 ErrorState
*/
enum OpenChaoJi_gbt27930_a_ErrorState {
    OPENCHAOJI_GBT27930_A_ERROR_STATE_NORMAL                 = 0x00,
    OPENCHAOJI_GBT27930_A_ERROR_STATE_TIMEOUT                = 0x01,
    OPENCHAOJI_GBT27930_A_ERROR_STATE_UNTRUSTED              = 0x02,
};

/**
 * 定义A类系统中止类型 EndCodeType
*/
#define OPENCHAOJI_GBT27930_A_END_CODE_SECC_NORMAL           0x01        // 达到充电机设定的条件中止、人工中止、接收到车辆发送的BST报文等
#define OPENCHAOJI_GBT27930_A_END_CODE_SECC_FAULT            0x02        // 故障中止
#define OPENCHAOJI_GBT27930_A_END_CODE_SECC_ERROR            0x03        // 错误中止
#define OPENCHAOJI_GBT27930_A_END_CODE_SECC_OTHER            0x04        // 其他

#define OPENCHAOJI_GBT27930_A_END_CODE_EVCC_NORMAL           0x01        // 达到车辆设定的条件中止、接收到充电机发送的CST报文等
#define OPENCHAOJI_GBT27930_A_END_CODE_EVCC_FAULT            0x02        // 故障中止
#define OPENCHAOJI_GBT27930_A_END_CODE_EVCC_ERROR            0x03        // 错误中止
#define OPENCHAOJI_GBT27930_A_END_CODE_EVCC_OTHER            0x04        // 其他

/**
 * 定义A类系统中止原因 EndReasonType
*/
// TODO: SECC
#define OPENCHAOJI_GBT27930_A_END_REASON_SECC_NORMAL_FINISHED       0x01        // 达到充电机设定的条件中止(如按金额充电、按时间充电，按SOC充电等), 正常结束
#define OPENCHAOJI_GBT27930_A_END_REASON_SECC_NORMAL_USER           0x02        // 人工中止(包括通信开始后由用户触发的主动中止充电)
#define OPENCHAOJI_GBT27930_A_END_REASON_SECC_NORMAL_BST            0x03        // 车辆主动中止(接收到车辆的BST报文)
#define OPENCHAOJI_GBT27930_A_END_REASON_SECC_NORMAL_OTHER          0x04        // 其他(预留)

#define OPENCHAOJI_GBT27930_A_END_REASON_SECC_FAULT_SELFCHECK       0x01        // 自检故障
#define OPENCHAOJI_GBT27930_A_END_REASON_SECC_FAULT_EMERGENCY       0x02        // 充电机紧急停止
#define OPENCHAOJI_GBT27930_A_END_REASON_SECC_FAULT_CC1             0x03        // 检测点1电压异常, 车辆连接不可靠
#define OPENCHAOJI_GBT27930_A_END_REASON_SECC_FAULT_LOCK            0x04        // 电子锁未可靠锁止
#define OPENCHAOJI_GBT27930_A_END_REASON_SECC_FAULT_BSM             0x05        // 电池状态异常
#define OPENCHAOJI_GBT27930_A_END_REASON_SECC_FAULT_PRECHARGE       0x06        // 预充故障
#define OPENCHAOJI_GBT27930_A_END_REASON_SECC_FAULT_OTHER           0x07        // 其他故障

#define OPENCHAOJI_GBT27930_A_END_REASON_SECC_ERROR_CURRENT         0x01        // 电流不匹配
#define OPENCHAOJI_GBT27930_A_END_REASON_SECC_ERROR_VOLTAGE         0x02        // 电压异常
#define OPENCHAOJI_GBT27930_A_END_REASON_SECC_ERROR_PARAM           0x03        // 充电参数不匹配

// TODO: EVCC
#define OPENCHAOJI_GBT27930_A_END_REASON_EVCC_NORMAL_SOC            0x01        // 达到所需求的SOC目标值
#define OPENCHAOJI_GBT27930_A_END_REASON_EVCC_NORMAL_VOLTAGE        0x02        // 达到总电压的设定值
#define OPENCHAOJI_GBT27930_A_END_REASON_EVCC_NORMAL_CELL_VOLTAGE   0x03        // 达到单体电压的设定值
#define OPENCHAOJI_GBT27930_A_END_REASON_EVCC_NORMAL_CST            0x04        // 充电机主动中止(接收到充电机的CST报文)
#define OPENCHAOJI_GBT27930_A_END_REASON_EVCC_NORMAL_OTHER          0x05        // 其他(预留)

#define OPENCHAOJI_GBT27930_A_END_REASON_EVCC_FAULT_COUPLER         0x01        // 充电耦合器连接故障
#define OPENCHAOJI_GBT27930_A_END_REASON_EVCC_FAULT_OVER_TEMPERA    0x02        // 电池组温度过高故障
#define OPENCHAOJI_GBT27930_A_END_REASON_EVCC_FAULT_CC2_VOLTAGE     0x03        // 检测点2电压检测故障
#define OPENCHAOJI_GBT27930_A_END_REASON_EVCC_FAULT_OTHER           0x04        // 其他故障

#define OPENCHAOJI_GBT27930_A_END_REASON_EVCC_ERROR_CURRENT         0x01        // 电流过大
#define OPENCHAOJI_GBT27930_A_END_REASON_EVCC_ERROR_VOLTAGE         0x02        // 电压异常
#define OPENCHAOJI_GBT27930_A_END_REASON_EVCC_ERROR_PARAM           0x03        // 充电参数不匹配

#endif  // OPENCHAOJI_CONFIG_ENABLE_GBT27930_A



/********************************** B类系统  **********************************/
#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B == CONFIG_YES)

/**
 * 定义B类系统模块序号分配, 用于module_status_id
 * 默认预留分配四个状态, 用于进行18487相关状态跳转
 * 1. 空闲IDLE, 常规状态, 处理非充电过程, 标准操作是检测到物理连接完成且本端确认启动充电过程后跳转到TRIGGER状态
 * 2. 触发Trigger, 启动充电流程, 在进入27930的第一个数据交互模块状态前进行必要的准备工作.
 *    例如进行传输层通信连接建立, 数据链路建立等. 厂家也可以在这里加入自定义功能, 例如启动指示灯等.
 *    准备工作确认后, 进入27930的第一个数据通信模块, 功能协商
 * 3. 结束End, 充电流程结束的最后一个状态, 对应于Trigger, 进行反向释放操作.
 *    连接断开后返回IDLE状态. 如App支持不重新插拔枪继续启动下一次交易, 也可以触发此状态进入IDLE.
 * 3. 故障Fault, 故障状态, 如果底层发现硬件级别故障, 则进入此状态, 保证App不再可以进入充电流程, 除非故障消失, 否则保持在此状态
 *    本状态只有从IDLE, END两个状态可以切换过来. 中间过程出现故障, 应当先进入停止流程, 到达END后再进入本状态
 *
*/
enum OpenChaoJi_gbt27930_b_module {

    OPENCHAOJI_GBT27930_B_MODULE_IDLE = 0,               //
    OPENCHAOJI_GBT27930_B_MODULE_TRIGGER,

    OPENCHAOJI_GBT27930_B_MODULE_FUNC_NEGO,
    OPENCHAOJI_GBT27930_B_MODULE_PARAM_CONFIG,

#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_AUTH == CONFIG_YES)
    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_AUTH_RFID == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_MODULE_AUTH_RFID,
    #endif
    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_AUTH_EVIN == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_MODULE_AUTH_EVIN,
    #endif
#endif

#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_RESERVE == CONFIG_YES)
    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_RESERVE_EVCC == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_MODULE_RESERVE,
    #endif
#endif

#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_SELFCHECK == CONFIG_YES)
    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_SELFCHECK_GENERAL == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_MODULE_SELFCHECK,
    #endif
#endif

#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_SUPPLY == CONFIG_YES)
    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_SUPPLY_BASIC == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_MODULE_SUPPLY,
    #endif
#endif

#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_CHARGING == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_MODULE_CHARGING,
#endif
#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_DISCHARGING == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_MODULE_DISCHARGING,
#endif

#if(OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_STATISTICS_STOPING  == CONFIG_YES)
    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_STATISTICS_STOPING_CHARGE == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_MODULE_STATISTICS_STOPING,
    #endif
#endif

#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_STATISTICS == CONFIG_YES)
    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_STATISTICS == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_MODULE_STATISTICS,
    #endif
#endif

#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_SERVICE_IDLE == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_MODULE_SERVICE_IDLE,
#endif

    OPENCHAOJI_GBT27930_B_MODULE_END,
    OPENCHAOJI_GBT27930_B_MODULE_FAULT,

    OPENCHAOJI_GBT27930_B_MODULE_NUM
};

/**
 * 定义B类系统地址分配
*/
#define OPENCHAOJI_GBT27930_B_CAN_ADDR_SECC              0x5F
#define OPENCHAOJI_GBT27930_B_CAN_ADDR_EVCC              0x25
#define OPENCHAOJI_GBT27930_B_CAN_ADDR_VACC              0x60

/**
 * 定义B类系统参数组标识码 PIDType
*/
enum OpenChaoJi_gbt27930_b_PIDType {
    OPENCHAOJI_GBT27930_B_PGI_FUNC_NEGO_SECC             = 0x11,     // 功能协商-充电机支持功能(FDC=1)
    OPENCHAOJI_GBT27930_B_PGI_FUNC_NEGO_EVCC             = 0x12,     // 功能协商-车辆功能协商结果(FDC=1)

    OPENCHAOJI_GBT27930_B_PGI_PARAM_CONFIG_SECC          = 0x21,     // 参数配置-充电机充电参数(FDC=1)
    OPENCHAOJI_GBT27930_B_PGI_PARAM_CONFIG_EVCC          = 0x22,     // 参数配置-车辆充电参数(FDC=1)

#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_AUTH == CONFIG_YES)

    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_AUTH_RFID == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_PGI_AUTH_RFID_PARAM_SECC         = 0x31,     // 鉴权-充电机鉴权参数(FDC=1 扫码/刷卡鉴权)
    OPENCHAOJI_GBT27930_B_PGI_AUTH_RFID_WAIT_EVCC          = 0x32,     // 鉴权-车辆鉴权等待(FDC=1 扫码/刷卡鉴权)
    OPENCHAOJI_GBT27930_B_PGI_AUTH_RFID_RESULT_SECC        = 0x33,     // 鉴权-鉴权结果(FDC=1 扫码/刷卡鉴权)
    #endif

    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_AUTH_EVIN == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_PGI_AUTH_EVIN_REQ_SECC          = 0x34,     // 鉴权-鉴权请求(FDC=2 EVIN鉴权)
    OPENCHAOJI_GBT27930_B_PGI_AUTH_EVIN_PARAM_EVCC        = 0x35,     // 鉴权-车辆鉴权参数(FDC=2 EVIN鉴权)
    OPENCHAOJI_GBT27930_B_PGI_AUTH_EVIN_RESULT_SECC       = 0x36,     // 鉴权-鉴权结果(FDC=2 EVIN鉴权)
    #endif

#endif

#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_RESERVE == CONFIG_YES)

    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_RESERVE_EVCC == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_PGI_RESERVE_INFO_SECC          = 0x41,     // 预约-充电机预约充电信息(FDC=1)
    OPENCHAOJI_GBT27930_B_PGI_RESERVE_CONFIRM_SECC       = 0x42,     // 预约-充电机预约充电确认(FDC=1)
    OPENCHAOJI_GBT27930_B_PGI_RESERVE_INFO_EVCC          = 0x43,     // 预约-车辆预约充电信息(FDC=1)
    OPENCHAOJI_GBT27930_B_PGI_RESERVE_NEGO_EVCC          = 0x44,     // 预约-车辆预约充电协商(FDC=1)
    #endif

#endif

#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_SELFCHECK == CONFIG_YES)

    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_SELFCHECK_GENERAL == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_PGI_SELFCHECK_STATUS_SECC      = 0x51,     // 系统自检-充电机自检状态(FDC=1)
    OPENCHAOJI_GBT27930_B_PGI_SELFCHECK_RESULT_SECC      = 0x52,     // 系统自检-充电机自检结果(FDC=1)
    #endif

#endif

#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_SUPPLY == CONFIG_YES)

    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_SUPPLY_BASIC == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_PGI_SUPPLY_STATUS_SECC         = 0x61,     // 供电模式-充电机供电状态(FDC=1)
    OPENCHAOJI_GBT27930_B_PGI_SUPPLY_STATUS_EVCC         = 0x62,     // 供电模式-车辆供电状态(FDC=1)
    OPENCHAOJI_GBT27930_B_PGI_SUPPLY_REQUIREMENT_EVCC    = 0x63,     // 供电模式-车辆供电需求(FDC=1)
    OPENCHAOJI_GBT27930_B_PGI_SUPPLY_ABILITY_SECC        = 0x64,     // 供电模式-充电机动态输出能力状态(FDC=1)
    OPENCHAOJI_GBT27930_B_PGI_SUPPLY_FINISH_EVCC         = 0x65,     // 供电模式-车辆供电完成(FDC=1)
    #endif

#endif

    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_CHARGING == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_PGI_CHARGING_READY_SECC           = 0x71,     // 预充及能量传输-充电机就绪状态(FDC=1 充电)
    OPENCHAOJI_GBT27930_B_PGI_CHARGING_READY_EVCC           = 0x72,     // 预充及能量传输-车辆就绪状态(FDC=1 充电)
    OPENCHAOJI_GBT27930_B_PGI_CHARGING_REQUIREMENT_EVCC     = 0x73,     // 预充及能量传输-车辆充电需求(FDC=1 充电)
    OPENCHAOJI_GBT27930_B_PGI_CHARGING_INFO_BASIC_EVCC      = 0x74,     // 预充及能量传输-车辆充电基本信息(FDC=1 充电)
    OPENCHAOJI_GBT27930_B_PGI_CHARGING_INFO_BATTERY_EVCC    = 0x75,     // 预充及能量传输-车辆充电电池基本信息(FDC=1 充电)
    OPENCHAOJI_GBT27930_B_PGI_CHARGING_ABILITY_SECC         = 0x76,     // 预充及能量传输-充电机动态输出能力(FDC=1 充电)
    OPENCHAOJI_GBT27930_B_PGI_CHARGING_PAUSE_SECC           = 0x77,     // 预充及能量传输-充电机暂停充电(FDC=1 充电)
    OPENCHAOJI_GBT27930_B_PGI_CHARGING_PAUSE_EVCC           = 0x78,     // 预充及能量传输-车辆暂停充电(FDC=1 充电)
    #endif

    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_DISCHARGING == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_PGI_DISCHARGING_READY_SECC        = 0x91,     // 预充及能量传输-充放电机就绪状态(FDC=2 放电)
    OPENCHAOJI_GBT27930_B_PGI_DISCHARGING_READY_EVCC        = 0x92,     // 预充及能量传输-车辆就绪状态(FDC=2 放电)
    OPENCHAOJI_GBT27930_B_PGI_DISCHARGING_REQUIREMENT_EVCC  = 0x93,     // 预充及能量传输-车辆放电需求(FDC=2 放电)
    OPENCHAOJI_GBT27930_B_PGI_DISCHARGING_STATUS_EVCC       = 0x94,     // 预充及能量传输-车辆放电状态(FDC=2 放电)
    OPENCHAOJI_GBT27930_B_PGI_DISCHARGING_INFO_BASIC_EVCC   = 0x95,     // 预充及能量传输-车辆放电基本信息(FDC=2 放电)
    OPENCHAOJI_GBT27930_B_PGI_DISCHARGING_ABILITY_SECC      = 0x96,     // 预充及能量传输-充放电机动态输出能力(FDC=2 放电)
    OPENCHAOJI_GBT27930_B_PGI_DISCHARGING_STATUS_SECC       = 0x97,     // 预充及能量传输-充放电机放电状态(FDC=2 放电)
    #endif


#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_STATISTICS == CONFIG_YES)

    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_STATISTICS == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_PGI_STATISTICS_SECC                    = 0x81,     // 服务统计-充电机统计信息报文(FDC=1)
    OPENCHAOJI_GBT27930_B_PGI_STATISTICS_EVCC                    = 0x82,     // 服务统计-车辆统计信息报文(FDC=1)
    #endif

#endif

    OPENCHAOJI_GBT27930_B_PGI_PUBLIC_PHASE_INFO_SECC             = 0x01,     // 公共报文-阶段确认报文-充电机阶段信息
    OPENCHAOJI_GBT27930_B_PGI_PUBLIC_PHASE_ACK_EVCC              = 0x02,     // 公共报文-阶段确认报文-车辆阶段信息
    OPENCHAOJI_GBT27930_B_PGI_PUBLIC_STOP_INFO_SECC              = 0x03,     // 公共报文-中止报文-充电机中止报文
    OPENCHAOJI_GBT27930_B_PGI_PUBLIC_STOP_INFO_EVCC              = 0x04,     // 公共报文-中止报文-车辆中止报文
    OPENCHAOJI_GBT27930_B_PGI_PUBLIC_RELAY_STATUS_SECC           = 0x05,     // 公共报文-接触器状态报文-充电机直流供电回路接触器状态报文
    OPENCHAOJI_GBT27930_B_PGI_PUBLIC_RELAY_STATUS_EVCC           = 0x06,     // 公共报文-接触器状态报文-车辆断开装置报文
    OPENCHAOJI_GBT27930_B_PGI_PUBLIC_LATCHING_STATUS_EVCC        = 0x07,     // 公共报文-电子锁状态报文-车辆电子锁状态报文

};



/**
 * 定义B类系统CAN类型 CANType
*/
enum OpenChaoJi_gbt27930_b_CANType {
    OPENCHAOJI_GBT27930_B_CAN_TYPE_20            = 0x00,
    OPENCHAOJI_GBT27930_B_CAN_TYPE_FD            = 0x01,
    OPENCHAOJI_GBT27930_B_CAN_TYPE_XL            = 0x02,
};



/**
 * 定义B类系统协议版本号 ProtocolVersionType
*/
#define OPENCHAOJI_GBT27930_B_PROTOCOL_VERSION_TYPE_MAKE(MAJOR,MINOR,TMP)   ((((int)MAJOR) << 16) | (((int)MINOR) << 8) | (((int)TMP) << 0))
#define OPENCHAOJI_GBT27930_B_PROTOCOL_VERSION_TYPE_MAJOR(VER)              ((((int)VER) >> 16) & 0xFF)
#define OPENCHAOJI_GBT27930_B_PROTOCOL_VERSION_TYPE_MINOR(VER)              ((((int)VER) >>  8) & 0xFF)
#define OPENCHAOJI_GBT27930_B_PROTOCOL_VERSION_TYPE_TMP(VER)                ((((int)VER) >>  0) & 0xFF)

#define OPENCHAOJI_GBT27930_B_PROTOCOL_VERSION_TYPE_2_0_0                   OPENCHAOJI_GBT27930_B_PROTOCOL_VERSION_TYPE_MAKE(2,0,0)

typedef unsigned long OpenChaoJi_gbt27930_b_ProtocolVersionType;



/**
 * 定义B类系统协商结果 VersionResultType
*/
enum OpenChaoJi_gbt27930_b_VersionResultType {
    OPENCHAOJI_GBT27930_B_VERSION_RESULT_TYPE_CONTINUE       = 0x00,
    OPENCHAOJI_GBT27930_B_VERSION_RESULT_TYPE_SUCCEED        = 0x01,
    OPENCHAOJI_GBT27930_B_VERSION_RESULT_TYPE_FAILED         = 0x02,
};



/**
 * 定义B类系统功能代码 FCType
*/
enum OpenChaoJi_gbt27930_b_FCType {
    OPENCHAOJI_GBT27930_B_FC_TYPE_FUNC_NEGO                      = 0x10,     // 功能协商
    OPENCHAOJI_GBT27930_B_FC_TYPE_PARAM_CONFIG                   = 0x20,     // 参数协商/参数配置
#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_AUTH == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_FC_TYPE_AUTH                           = 0x30,     // 鉴权
#endif
#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_RESERVE == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_FC_TYPE_RESERVE                        = 0x40,     // 预约
#endif
#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_SELFCHECK == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_FC_TYPE_SELFCHECK                      = 0x50,     // 系统自检
#endif
#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_SUPPLY == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_FC_TYPE_SUPPLY                         = 0x60,     // 供电模式
#endif
    OPENCHAOJI_GBT27930_B_FC_TYPE_ENERGY                         = 0x70,     // 预充及能量传输
#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_STATISTICS == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_FC_TYPE_STATISTICS                     = 0x80,     // 服务统计
#endif
#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_SERVICE_IDLE == CONFIG_YES)
    OPENCHAOJI_GBT27930_B_FC_TYPE_SERVICE_IDLE                   = 0x90,     // 服务空闲
#endif

    OPENCHAOJI_GBT27930_B_FC_TYPE_SERVICE_STOPPING               = 0xF0,
};



/**
 * 定义B类系统功能描述码 FDCType
*/
#define OPENCHAOJI_GBT27930_B_FDC_NOT_SUPPORT                    0           // EVCC不支持

/* 功能协商 - 公用功能协商(FDC=1) */
#define OPENCHAOJI_GBT27930_B_FDC_FUNC_NEGO_GENERAL              1

/* 参数配置 - 基本参数配置(FDC=1) */
#define OPENCHAOJI_GBT27930_B_FDC_PARAM_CONFIG_GENERAL           1

/* 鉴权 */
#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_AUTH == CONFIG_YES)

    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_AUTH_RFID == CONFIG_YES)
    /* 鉴权 - RFID模式(FDC=1) */
    #define OPENCHAOJI_GBT27930_B_FDC_AUTH_RFID                  1
    #endif

    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_AUTH_EVIN == CONFIG_YES)
    /* 鉴权 - EVIN模式(FDC=2) */
    #define OPENCHAOJI_GBT27930_B_FDC_AUTH_EVIN                  2
    #endif

#endif

/* 预约 */
#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_RESERVE == CONFIG_YES)

    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_RESERVE_EVCC == CONFIG_YES)
    /* 预约 - 车辆预约模式(FDC=1) */
    #define OPENCHAOJI_GBT27930_B_FDC_RESERVE_EVCC               1
    #endif

#endif

/* 系统自检 */
#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_SELFCHECK == CONFIG_YES)

    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_SELFCHECK_GENERAL == CONFIG_YES)
    /* 系统自检 - 通用系统自检(FDC=1) */
    #define OPENCHAOJI_GBT27930_B_FDC_SELFCHECK_GENERAL          1
    #endif

#endif

/* 供电模式 */
#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_SUPPLY == CONFIG_YES)

    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_SUPPLY_BASIC == CONFIG_YES)
    /* 供电模式 - 基本供电模式(FDC=1) */
    #define OPENCHAOJI_GBT27930_B_FDC_SUPPLY_BASIC               1
    #endif

#endif

#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_CHARGING == CONFIG_YES)
/* 预充及能量传输 - 充电模式能量传输(FDC=1) */
#define OPENCHAOJI_GBT27930_B_FDC_CHARGING                  1
#endif

#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_DISCHARGING == CONFIG_YES)
/* 预充及能量传输 - 充电模式能量传输(FDC=1) */
#define OPENCHAOJI_GBT27930_B_FDC_DISCHARGING               2
#endif


/* 服务统计 */
#if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FUNC_STATISTICS == CONFIG_YES)

    #if (OPENCHAOJI_CONFIG_ENABLE_GBT27930_B_FDC_STATISTICS == CONFIG_YES)
    /* 供电模式 - 基本供电模式(FDC=1) */
    #define OPENCHAOJI_GBT27930_B_FDC_STATISTICS          1
    #endif

#endif



/**
 * 定义B类系统FDC的支持情况 FDCSupportType
*/
enum OpenChaoJi_gbt27930_b_FDCSupportType{
    OPENCHAOJI_GBT27930_B_FDC_SUPPORT_TYPE_SUPPORT           = 0x01,
    OPENCHAOJI_GBT27930_B_FDC_SUPPORT_TYPE_NOT_SUPPORT       = 0x00,
};

/**
 * 定义B类系统自检检测状态 CheckType
*/
enum OpenChaoJi_gbt27930_b_CheckType {
    OPENCHAOJI_GBT27930_B_CHECK_TYPE_NOT_CHECK               = 0x00,
    OPENCHAOJI_GBT27930_B_CHECK_TYPE_CHECKING                = 0x01,
    OPENCHAOJI_GBT27930_B_CHECK_TYPE_CHECK_FINISHED          = 0x02,
};

/**
 * 定义B类系统自检结果 CheckResult
*/
enum OpenChaoJi_gbt27930_b_CheckResult {
    OPENCHAOJI_GBT27930_B_CHECK_RESULT_FAILED                = 0x00,
    OPENCHAOJI_GBT27930_B_CHECK_RESULT_SUCCEED               = 0xAA,
};

/**
 * 定义B类系统电子锁状态 LatchingStatusType
*/
enum OpenChaoJi_gbt27930_b_LatchingStatusType {
    OPENCHAOJI_GBT27930_B_LATCHING_STATUS_TYPE_NOT_LOCK      = 0x00,
    OPENCHAOJI_GBT27930_B_LATCHING_STATUS_TYPE_LOCKED        = 0xAA,
};

/**
 * 定义B类系统就绪状态 ReadyType
*/
enum OpenChaoJi_gbt27930_b_ReadyType {
    OPENCHAOJI_GBT27930_B_READY_TYPE_NOT_READY               = 0x00,
    OPENCHAOJI_GBT27930_B_READY_TYPE_READY                   = 0xAA,
};

/**
 * 定义B类系统电压 VoltageType1/VoltageTyp2/CurrentType/SOCType/CapacityType/MTimeType
*/
typedef unsigned short OpenChaoJi_gbt27930_b_VoltageType1;            // 电压 分辨率0.1V
typedef unsigned short OpenChaoJi_gbt27930_b_VoltageType2;            // 电压 分辨率0.001V
typedef unsigned short OpenChaoJi_gbt27930_b_CurrentType;             // 电流 分辨率0.1A
typedef unsigned short OpenChaoJi_gbt27930_b_SOCType;                 // SoC 分辨率0.1%
typedef unsigned short OpenChaoJi_gbt27930_b_CapcityType;             // 能量 分辨率0.1kWh
typedef unsigned short OpenChaoJi_gbt27930_b_MTimeType;               // 时间 分辨率1min
typedef unsigned short OpenChaoJi_gbt27930_b_ChargingRateType;        // 电流调整速率 分辨率1A/s
typedef unsigned short OpenChaoJi_gbt27930_b_PowerType;               // 输出功率 分辨率0.1kW
typedef unsigned char  OpenChaoJi_gbt27930_b_PowerProIntType;         // 时刻编码 分辨率1
typedef unsigned short OpenChaoJi_gbt27930_b_PowerProType;            // 输出功率百分比 分辨率0.1%
typedef unsigned long  OpenChaoJi_gbt27930_b_CycleIndexType;          // 循环次数 分辨率0.1次
typedef unsigned long  OpenChaoJi_gbt27930_b_KilometerType;           // 里程 分辨率0.1km
typedef unsigned short OpenChaoJi_gbt27930_b_TemperatureTyp1;         // 温度 分辨率1℃ 偏移量 -40℃
typedef unsigned short OpenChaoJi_gbt27930_b_TemperatureTyp2;         // 温度 分辨率1℃ 偏移量 -50℃


/**
 * 定义B类系统充电模式 ChargeModeType
*/
enum OpenChaoJi_gbt27930_b_ChargeModeType {
    OPENCHAOJI_GBT27930_B_CHARGE_MODE_TYPE_CURRENT           = 0x01,
    OPENCHAOJI_GBT27930_B_CHARGE_MODE_TYPE_VOLTAGE           = 0x02,
};

/**
 * 定义B类系统车辆结束供电请求 PowerSupplyEndType
*/
enum OpenChaoJi_gbt27930_b_PowerSupplyEndType {
    OPENCHAOJI_GBT27930_B_POWER_SUPPLY_END_TYPE_END          = 0xAA,
    OPENCHAOJI_GBT27930_B_POWER_SUPPLY_END_TYPE_INVALID      = 0x00,
};

/**
 * 定义B类系统输出能力变化原因 ReasonType
*/
enum OpenChaoJi_gbt27930_b_ReasonType {
    OPENCHAOJI_GBT27930_B_REASON_TYPE_GRID                   = 0x01,
    OPENCHAOJI_GBT27930_B_REASON_TYPE_CHARGER                = 0x02,
    OPENCHAOJI_GBT27930_B_REASON_TYPE_OTHER                  = 0x03,
};

/**
 * 定义B类系统中止类型 EndCodeType
*/
#define OPENCHAOJI_GBT27930_B_END_CODE_SECC_TERM             0x01        // 停机
#define OPENCHAOJI_GBT27930_B_END_CODE_SECC_COMM_TIMEOUT     0x02        // 功能模块通信超时
#define OPENCHAOJI_GBT27930_B_END_CODE_SECC_FAILED           0x03        // 执行失败
#define OPENCHAOJI_GBT27930_B_END_CODE_SECC_OTHER            0x04        // 其他

#define OPENCHAOJI_GBT27930_B_END_CODE_EVCC_TERM             0x01        // 中止充电
#define OPENCHAOJI_GBT27930_B_END_CODE_EVCC_COMM_TIMEOUT     0x02        // 功能模块通信超时
#define OPENCHAOJI_GBT27930_B_END_CODE_EVCC_FAILED           0x03        // 执行失败
#define OPENCHAOJI_GBT27930_B_END_CODE_EVCC_OTHER            0x04        // 其他

/**
 * 定义B类系统中止原因 EndReasonType
*/
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_TERM_NORMAL            0x01    // 充电机正常停机
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_TERM_FAILURE           0x02    // 充电机除通信超时外的故障停机
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_TERM_EMERGENCY         0x03    // 充电机紧急停止
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_TERM_SELFPROTECT       0x04    // 充电机主动防护

#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_TIMEOUT_FUNC_NEGO      0x01    // 充电机通信超时-功能协商
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_TIMEOUT_PARAM_CONFIG   0x02    // 充电机通信超时-参数配置
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_TIMEOUT_AUTH           0x03    // 充电机通信超时-鉴权
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_TIMEOUT_RESERVE        0x04    // 充电机通信超时-预约
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_TIMEOUT_SELFCHECK      0x05    // 充电机通信超时-自检
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_TIMEOUT_SUPPLY         0x06    // 充电机通信超时-供电模式
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_TIMEOUT_ENERGY         0x07    // 充电机通信超时-预充
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_TIMEOUT_STATISTICS     0x08    // 充电机通信超时-服务统计
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_TIMEOUT_SERVICE_IDLE   0x09    // 充电机通信超时-服务空闲

#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_FAILED_FUNC_NEGO       0x01     // 充电机执行失败-功能协商失败
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_FAILED_PARAM_CONFIG    0x02     // 充电机执行失败-参数不匹配
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_FAILED_AUTH            0x03     // 充电机执行失败-鉴权执行失败
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_FAILED_RESERVE         0x04     // 充电机执行失败-预约执行失败
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_FAILED_SELFCHECK       0x05     // 充电机执行失败-自检失败
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_FAILED_SUPPLY          0x06     // 充电机执行失败-供电模式实行失败
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_FAILED_ENERGY          0x07     // 充电机执行失败-预充失败
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_FAILED_STATISTICS      0x08     // 充电机执行失败-服务统计执行失败
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_FAILED_SERVICE_IDLE    0x09     // 充电机执行失败-服务空闲执行失败
#define OPENCHAOJI_GBT27930_B_END_REASON_SECC_FAILED_PHASE           0x0A     // 充电机执行失败-阶段确认失败


#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_TERM_NORMAL            0x01    // 车辆正常停机
#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_TERM_FAILURE           0x02    // 车辆除通信超时外的故障停机
#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_TERM_EMERGENCY         0x03    // 车辆紧急停止

#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_TIMEOUT_FUNC_NEGO      0x01    // 车辆通信超时-功能协商
#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_TIMEOUT_PARAM_CONFIG   0x02    // 车辆通信超时-参数配置
#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_TIMEOUT_AUTH           0x03    // 车辆通信超时-鉴权
#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_TIMEOUT_RESERVE        0x04    // 车辆通信超时-预约
#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_TIMEOUT_SELFCHECK      0x05    // 车辆通信超时-自检
#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_TIMEOUT_SUPPLY         0x06    // 车辆通信超时-供电模式
#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_TIMEOUT_ENERGY         0x07    // 车辆通信超时-预充
#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_TIMEOUT_STATISTICS     0x08    // 车辆通信超时-服务统计
#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_TIMEOUT_SERVICE_IDLE   0x09    // 车辆通信超时-服务空闲

#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_FAILED_FUNC_NEGO       0x01    // 车辆执行失败-功能协商
#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_FAILED_PARAM_CONFIG    0x02    // 车辆执行失败-参数不匹配
#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_FAILED_AUTH            0x03    // 车辆执行失败-鉴权执行失败
#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_FAILED_RESERVE         0x04    // 车辆执行失败-预约执行失败
#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_FAILED_SELFCHECK       0x05    // 车辆执行失败-自检失败
#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_FAILED_SUPPLY          0x06    // 车辆执行失败-供电模式实行失败
#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_FAILED_ENERGY          0x07    // 车辆执行失败-预充失败
#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_FAILED_STATISTICS      0x08    // 车辆执行失败-服务统计执行失败
#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_FAILED_SERVICE_IDLE    0x09    // 车辆执行失败-服务空闲执行失败
#define OPENCHAOJI_GBT27930_B_END_REASON_EVCC_FAILED_PHASE           0x0A    // 车辆执行失败-阶段确认失败


/**
 * 定义B类系统故障代码 FaultType
 *
*/
// TODO: NB/T 10905-2021

/**
 * 定义B类阶段确认信息 PhaseACKType
*/
enum OpenChaoJi_gbt27930_b_PhaseACKType {
    OPENCHAOJI_GBT27930_B_PHASE_ACK_FAILED                   = 0x00,
    OPENCHAOJI_GBT27930_B_PHASE_ACK_SUCCEED                  = 0xAA,
};

/**
 * 定义B类接触器状态 ContactStatusType
*/
enum OpenChaoJi_gbt27930_b_ContactStatusType {
    OPENCHAOJI_GBT27930_B_CONTACT_STATUS_OPENED              = 0x00,
    OPENCHAOJI_GBT27930_B_CONTACT_STATUS_CLOSED              = 0xAA,
};

/**
 * 定义B类充电机鉴权状态 CAuthenStatusType
*/
enum OpenChaoJi_gbt27930_b_CAuthenStatusType {
    OPENCHAOJI_GBT27930_B_SECC_AUTH_STATUS_START_CONTINUE    = 0x00,
    OPENCHAOJI_GBT27930_B_SECC_AUTH_STATUS_FINISHED          = 0xAA,
};

/**
 * 定义B类车辆等待鉴权状态 VAuthenStatusType
*/
enum OpenChaoJi_gbt27930_b_VAuthenStatusType {
    OPENCHAOJI_GBT27930_B_EVCC_AUTH_STATUS_WAIT_REJECTED     = 0x00,
    OPENCHAOJI_GBT27930_B_EVCC_AUTH_STATUS_WAIT_CONTINUE     = 0xAA,
};

/**
 * 定义B类鉴权结果 AuthenResultType
*/
enum OpenChaoJi_gbt27930_b_AuthenResultType {
    OPENCHAOJI_GBT27930_B_AUTH_RESULT_FAILED                 = 0x00,
    OPENCHAOJI_GBT27930_B_AUTH_RESULT_SUCCEED                = 0xAA,
};

/**
 * 定义B类扩展车辆识别码 EVINType
*/
#define OPENCHAOJI_GBT27930_B_EVIN_LENGTH     17
typedef char OpenChaoJi_gbt27930_b_EVINType[OPENCHAOJI_GBT27930_B_EVIN_LENGTH + 1];

/**
 * 定义B类预约确认 ScheACKType
*/
enum OpenChaoJi_gbt27930_b_ScheACKType {
    OPENCHAOJI_GBT27930_B_SCHE_ACK_FAILED                    = 0x00,
    OPENCHAOJI_GBT27930_B_SCHE_ACK_SUCCEED                   = 0xAA,
};

/**
 * 定义B类预约协商结果 ScheNegoType
*/
enum OpenChaoJi_gbt27930_b_ScheNegoType {
    OPENCHAOJI_GBT27930_B_SCHE_NEGO_FAILED                   = 0x00,
    OPENCHAOJI_GBT27930_B_SCHE_NEGO_SUCCEED                  = 0xAA,
};

/**
 * 定义B类立即充电标识位 SupportChargeType
*/
enum OpenChaoJi_gbt27930_b_SupportChargeType {
    OPENCHAOJI_GBT27930_B_SUPPORT_CHARGE_TYPE_NO             = 0x00,
    OPENCHAOJI_GBT27930_B_SUPPORT_CHARGE_TYPE_YES            = 0xAA,
    OPENCHAOJI_GBT27930_B_SUPPORT_CHARGE_TYPE_CONFIRM        = 0xFF,
};

/**
 * 定义B类暂停状态 PauseStatusType
*/
enum OpenChaoJi_gbt27930_b_PauseStatusType {
    OPENCHAOJI_GBT27930_B_PAUSE_STATUS_PAUSE                 = 0xAA,
    OPENCHAOJI_GBT27930_B_PAUSE_STATUS_CHARGE                = 0x00,
};

/**
 * 定义B类适配器类型 AdaptorType
*/
enum OpenChaoJi_gbt27930_b_AdaptorType {
    OPENCHAOJI_GBT27930_B_ADAPTOR_A                          = 0x01,
    OPENCHAOJI_GBT27930_B_ADAPTOR_B                          = 0x02,
};



#endif  // OPENCHAOJI_CONFIG_ENABLE_GBT27930_B


#endif


